{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<LinkedBlock
  @params={{array
    (concat "vault.cluster.secrets.backend." (if @item.isFolder "list" "show") (unless @item.id "-root"))
    @item.id
  }}
  class="list-item-row"
  data-test-secret-link={{@item.id}}
  @encode={{true}}
  @queryParams={{secret-query-params @backendModel.type @item.type}}
>
  <div class="columns is-mobile">
    <div class="column is-10">
      <SecretLink
        @mode={{if @item.isFolder "list" "show"}}
        @secret={{@item.id}}
        @queryParams={{secret-query-params @backendModel.type @item.type asQueryParams=true}}
        class="has-text-black has-text-weight-semibold"
      >
        {{#if (eq @backendModel.type "transit")}}
          <Icon @name="key" class="has-text-grey-light" />
        {{else}}
          <Icon @name={{if @item.isFolder "folder" (or @item.icon "file")}} class="has-text-grey-light" />
        {{/if}}
        {{if (eq @item.id " ") "(self)" (or @item.keyWithoutParent @item.id)}}
      </SecretLink>
    </div>
    <div class="column has-text-right">
      <PopupMenu name="secret-menu">
        <Confirm as |c|>
          <nav class="menu">
            <ul class="menu-list">
              {{#if @item.isFolder}}
                <SecretLink @mode="list" @secret={{@item.id}} class="has-text-black has-text-weight-semibold">
                  Contents
                </SecretLink>
              {{else}}
                {{#if (or @item.versionPath.isLoading @item.secretPath.isLoading)}}
                  <li class="action">
                    <LoadingDropdownOption />
                  </li>
                {{else}}
                  {{#if @item.canRead}}
                    <li class="action">
                      <SecretLink
                        @mode="show"
                        @secret={{@item.id}}
                        @queryParams={{secret-query-params @backendModel.type @item.type asQueryParams=true}}
                        class="has-text-black has-text-weight-semibold"
                      >
                        Details
                      </SecretLink>
                    </li>
                  {{/if}}
                  {{#if @item.canEdit}}
                    <li class="action">
                      <SecretLink
                        @mode="edit"
                        @secret={{@item.id}}
                        @queryParams={{secret-query-params @backendModel.type @item.type asQueryParams=true}}
                        class="has-text-black has-text-weight-semibold"
                      >
                        Edit
                      </SecretLink>
                    </li>
                  {{/if}}
                  {{#if @item.canDelete}}
                    <li class="action">
                      <c.Message
                        @id={{@item.id}}
                        @triggerText="Delete"
                        @message="This will permanently delete this secret."
                        @onConfirm={{@delete}}
                      />
                    </li>
                  {{/if}}
                {{/if}}
              {{/if}}
            </ul>
          </nav>
        </Confirm>
      </PopupMenu>
    </div>
  </div>
</LinkedBlock>